package com.spc.service;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.spc.bean.Bis_sms_record;
import com.spc.mapper.Bis_sms_recordMapper;
import com.xbw.bean.Sys_User;

@Service
@Transactional
public class Bis_sms_recordServicelmpl implements Bis_sms_recordService{

	@Autowired
	HttpSession Session;
	
	@Autowired
	private Bis_sms_recordMapper bis_sms_recordMapper;
	
	@Transactional(propagation=Propagation.REQUIRED)
	@Override
	public void save(Bis_sms_record bis_sms_record) {
		Sys_User user = (Sys_User) Session.getAttribute("sysuser");
		bis_sms_record.setCreate_user_id(user.getUser_id());
		bis_sms_record.setUser_type(user.getUser_type());
		bis_sms_record.setSend_user_id(bis_sms_recordMapper.queryUser_id(bis_sms_record.getMobile()));
		this.bis_sms_recordMapper.save(bis_sms_record);
	}

	@Transactional(propagation=Propagation.SUPPORTS)
	@Override
	public List<Bis_sms_record> listAll(Map map) {
		return this.bis_sms_recordMapper.listAll(map);
	}

	@Transactional(propagation=Propagation.REQUIRED)
	@Override
	public void delete(String record_id) {
		String[] array=record_id.split(",");
		for(String arr:array){
			if(arr!=null&&!arr.equals("")){
				this.bis_sms_recordMapper.delete(arr);
			}
		}
	}

	@Override
	public int getCount(Map map) {
		return this.bis_sms_recordMapper.getCount(map);
	}
	
}
